package org.sag.mallbf;

import org.sag.mallbf.type.DataType;

import java.io.DataOutputStream;
import java.util.List;
import java.util.Map;

/**
 * Group Spec
 *
 * --> Version (As Int32)
 * Int16 Type: GROUP
 * Int16 ContentType: Vertex/etc.
 *
 * --> Version Info
 * Custom Headers
 * Int32 Trunk Type Count
 *
 * --> Typed Trunks
 * Int32 Element Count
 * Int32 Typed Word
 * Int32 * 3 (width is no sense)
 *
 * -> Typed Word Spec
 * Int16 Size in bytes (positive: little endian, negative: big endian)
 * Int16 Type: Int 0, Float 1
 */
public abstract class ObjGroup {
    Map<Integer, List<double[]>> value;
    String g;
    boolean inited = false;

    public void exportTo(DataOutputStream dos, int version) throws Exception {
        Utils.putShort(dos, (short) DataType.GROUP.getValue(), 0);
        Utils.putShort(dos, (short) 0, 0);

        exportHeader(dos, version);

        exportContent(dos);
    }

    /*
     * Export ContentType and Version Header
     */
    public abstract void exportHeader(DataOutputStream dos, int version) throws Exception;

    /*
     * Export Data Content
     */
    public abstract void exportContent(DataOutputStream dos) throws Exception;
}
